<?php 

namespace Cli\Event;

use Think\Log;
use Api\Event\CacheEvent;
use Api\Manage\SysNoticeManage;

// +----------------------------------------------------------------------
// | 文件 VideoplayTaskEvent.class.php
// +----------------------------------------------------------------------
// | 说明 视频播放增加
// +----------------------------------------------------------------------
// | 
// +----------------------------------------------------------------------
// | Author: 谢赤心 Legend. <xcx_legender@qq.com>
// +----------------------------------------------------------------------

class VideoplayTaskEvent extends TaskEvent
{
 
    public function run(&$param)
    {
        if(!$param){
            return;
        }
        
        $statisEvent = event('Statis');
        $videService = service('Video');
        $videoEvent  = event('Video');

        extract($param);

        $statisEvent->operStatisVideo($video_id, 0, 'play', $step, $extend);
        $save = [
            'id'   => (int)$video_id,
            'play' => ['inc', $step],
        ];
        $videService->save($save);
        $video = $videoEvent->detail($video_id);
        if ($video['type'] == 0){
            $statisEvent->inRank($video_id, $step);
        } 
        SysNoticeManage::afterPlay($video, $user, $step);
        // echo $video_id,':ok\r\n';
    }

}